package com.example.administrator.testproject.MVP.Recilte;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.administrator.testproject.MVP.Base.BaseActivity;
import com.example.administrator.testproject.MVP.Entity.DetectListItemDto;
import com.example.administrator.testproject.R;

import butterknife.BindView;

/**
 * Created by Administrator on 2016/10/20 0020.
 */

public class DetailPageActivity extends BaseActivity {

    @BindView(R.id.textView)
    TextView textView;
    @BindView(R.id.textView2)
    TextView textView2;
    @BindView(R.id.imageView)
    ImageView imageView;

    private DetectListItemDto Dto;

    @Override
    protected int setContentViews() {
        return R.layout.detailpage_layout;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Dto = (DetectListItemDto) getIntent().getSerializableExtra("Dto");
        RetileMain retileMain = new RetileMain();
        try {
            retileMain.doDetectJandanDetailPageData(Dto.getItemUrl(), new RetileMain.simpleListener() {
                @Override
                public void onListener() {

                }

                @Override
                public void onDetailListener(final String str) {
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            textView.setText(Dto.getTitle());
                            textView2.setText(str);
                            Glide.with(DetailPageActivity.this)
                                    .load(Dto.getItemImgUrl())
                                    .crossFade()
                                    .placeholder(R.mipmap.ic_launcher)
                                    .into(imageView);
                        }
                    });
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
